import { ActorLocationSender } from "../../../../Model/Server/Module/ActorLocation/ActorLocationSender";
import { ObjectSystemAttribute, FriendOf } from "../../../../../Decorator/Decorator";
import { AwakeSystem } from "../../../../../Core/Module/EventSystem/IAwakeSystem";
import { DestroySystem } from "../../../../../Core/Module/EventSystem/IDestroySystem";
import { TimeHelper } from "../../../../../Core/Module/Time/TimeHelper";
import { Log } from "../../../../../Core/Module/Log/Log";

@FriendOf(ActorLocationSender)
@ObjectSystemAttribute()
export class ActorLocationSenderAwakeSystem extends AwakeSystem<ActorLocationSender> {

    Awake(self: ActorLocationSender): void {
        self.LastSendOrRecvTime = TimeHelper.ServerNow();
        self.ActorId = 0;
        self.Error = 0;
    }

}

@FriendOf(ActorLocationSender)
@ObjectSystemAttribute()
export class ActorLocationSenderDestroySystem extends DestroySystem<ActorLocationSender> {

    Destroy(self: ActorLocationSender): void {
        Log.Debug(`actor location remove: ${self.Id}`);
        self.LastSendOrRecvTime = 0;
        self.ActorId = 0;
        self.Error = 0;
    }

}